package com.example.demohello.mapper;
import com.example.demohello.entity.Student;
import com.example.demohello.vo.StudentRequestBo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentMapper {

    @Insert("insert into student(student_id, student_name, student_birthday,student_sex) values( #{studentId}, #{studentName}, #{studentBirthday}, #{studentSex})")
    Integer addStudent(Student student);

    @Delete("delete from student  where student_id =  #{studentId}")
    Integer deleteStudent(Integer studentId);


    @Select("select * from student")
    @Results({
            @Result(property = "studentId",column = "student_id"),
            @Result(property = "studentName",column = "student_name"),
            @Result(property = "studentBirthday",column = "student_birthday"),
            @Result(property = "studentSex",column = "student_sex"),
    })
    List<Student> selectStudent();

    @Select("select * from student where student_id =  #{studentId}")
    @Results({
            @Result(property = "studentId",column = "student_id"),
            @Result(property = "studentName",column = "student_name"),
            @Result(property = "studentBirthday",column = "student_birthday"),
            @Result(property = "studentSex",column = "student_sex"),
    })
    Student selectOneStudent(Integer studentId);



    @Update("update student set student_name = #{studentName},student_birthday = #{studentBirthday},student_sex = #{studentSex} where student_id =  #{studentId}")
    Integer updateStudent(Student course);


    List<Student> selectForStudentList(StudentRequestBo requestBo);


    Integer selectCountStudent(StudentRequestBo requestBo);
}
